#ifndef __SI24R1_PORT_H_
#define __SI24R1_PORT_H_
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

#include <rtthread.h>
#include <rtdevice.h>

typedef struct hal_si24r1_port
{
    const struct hal_si24r1_port_ops *ops;
    int ce_pin;
    int irq_pin;
    void(*_irq_cb)(void *param);
    struct rt_spi_device *spi;
}si24ri_port_t;

struct hal_si24r1_port_ops
{
    // int (*send_then_recv)(struct hal_si24r1_port *halport, const uint8_t *tbuf, uint8_t tlen, uint8_t *rbuf, uint8_t rlen);
    // int (*send_then_send)(struct hal_si24r1_port *halport, const uint8_t *buf1, uint8_t len1, const uint8_t *buf2, uint8_t len2);
    // int (*write)(struct hal_si24r1_port *halport, const uint8_t *buf, uint8_t len);
    int (*read_reg)(struct hal_si24r1_port *halport, uint8_t reg, uint8_t *buf, uint8_t len);
    int (*write_reg)(struct hal_si24r1_port *halport, uint8_t reg, uint8_t *buf, uint8_t len);
    int (*write)(struct hal_si24r1_port *halport, uint8_t cmd, uint8_t *buf, uint8_t len);
    int (*read)(struct hal_si24r1_port *halport, uint8_t cmd, uint8_t *buf, uint8_t len);
    void (*set_ce)(struct hal_si24r1_port *halport);
    void (*reset_ce)(struct hal_si24r1_port *halport);
    int (*read_irq_pin)(struct hal_si24r1_port *halport);
};
int hal_si24r1_port_init(
    struct hal_si24r1_port* halport,
    char* spi_dev_name,
    int ce_pin,
    int irq_pin,
    void(*irq_callback)(void* param),
    void* param);

#ifdef __cplusplus
}
#endif // __cplusplus
#endif